/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.i
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*******************************************************************************
 * Filename:
 * ---------
 * med_mem.h
 *
 * Project:
 * --------
 *   Maui
 *
 * Description:
 * ------------
 *   This file includes media memory configuration.
 *
 * Author:
 * -------
 * -------
 *
 *==============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *==============================================================================
 *******************************************************************************/

//#ifndef MED_NOT_PRESENT

#ifndef _MED_MEM_H
#define _MED_MEM_H

#include "med_global.h" 
/* for lcd size */
#include "lcd_Sw_inc.h"

#if defined(__J2ME__)
#include "j2me_custom_option.h"
#include "j2me_custom_param.h"
#endif

#define MED_1_SCENARIO_DEFAULT (MED_MEM_EXT_DEFAULT_SIZE)
#define MED_1_SCENARIO_CAM_CAPTURE (MAX_MED_CAM_CAP_EXT_MEM_SIZE)
#define MED_1_SCENARIO_JPG_DECODE (MAX_MED_JPG_DEC_EXT_MEM_SIZE)
#define MED_1_SCENARIO_JPG_ENCODE (MAX_MED_JPG_ENC_EXT_MEM_SIZE)
#define MED_1_SCENARIO_VID_ENCODE (MAX_MED_VID_ENC_EXT_MEM_SIZE)
#define MED_1_SCENARIO_VID_DECODE (MAX_MED_VID_DEC_EXT_MEM_SIZE)
#define MED_1_SCENARIO_VDOEDT (MAX_VID_EDT_EXT_MEM_SIZE)
#define MED_1_SCENARIO_WEBCAM (MAX_MED_WEBCAM_EXT_MEM_SIZE)
#define MED_1_SCENARIO_MMS_SUPPORT (MAX_MMS_RESIZE_IMAGE_BUF_SIZE)
#define MED_1_SCENARIO_BARCODE (MAX_BARCODE_EXT_MEM_SIZE)
#define MED_1_SCENARIO_VOIP (MAX_VOIP_EXT_MEM_SIZE)
#define MED_1_SCENARIO_STREAMING (MAX_STREAMING_EXT_MEM_SIZE)
#define MED_1_SCENARIO_J2ME (MAX_J2ME_EXT_MEM_SIZE)
#define MED_1_SCENARIO_SWFLASH (MAX_MED_SWFLASH_EXT_MEM_SIZE)
#define MED_1_SCENARIO_M3D (MAX_M3D_EXT_MEM_SIZE)
#define MED_1_SCENARIO_3D_GAME (MAX_3D_GAME_EXT_MEM_SIZE)
#define MED_1_SCENARIO_AUD (AUD_EXT_MEM_SIZE)
#define MED_1_SCENARIO_TDMB (MAX_TDMB_EXT_MEM_SIZE)
#define MED_1_SCENARIO_CMMB (MAX_CMMB_EXT_MEM_SIZE)
#define MED_1_SCENARIO_FS_SORT (MAX_FS_SORT_MEM_SIZE)
#define MED_1_SCENARIO_CAM_PREVIEW (MAX_MED_CAM_PREVIEW_EXT_MEM_SIZE)
#define MED_1_SCENARIO_CAM_BCR (MAX_BCR_EXT_MEM_SIZE)
#define MED_1_SCENARIO_STITCH_PANORAMA (MAX_CAM_PANORAMA_EXT_MEM_SIZE)
#define MED_1_SCENARIO_IVEX (MAX_IVEX_MEM_SIZE)

#define MED_2_SCENARIO_JPG_ENCODE_W_AUD_TDMB (MAX_MED_JPG_ENC_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_2_SCENARIO_SWFLASH_W_AUD_TDMB (MAX_MED_SWFLASH_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_2_SCENARIO_STREAMING_W_AUD_TDMB (MAX_STREAMING_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_2_SCENARIO_MMS_SUPPORT_W_AUD_TDMB (MAX_MMS_RESIZE_IMAGE_BUF_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_2_SCENARIO_TDMB_W_AUD (MAX_TDMB_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE)
#define MED_2_SCENARIO_CMMB_W_AUD (MAX_CMMB_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE)
#define MED_2_SCENARIO_WEBCAM_W_TDMB (MAX_MED_WEBCAM_EXT_MEM_SIZE + MTV_BG_RECORD_MEM_SIZE)
#define MED_2_SCENARIO_GGLIVE_W_AUD (MAX_GGLIVE_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE)
#define MED_2_SCENARIO_STREAMING_W_AUD_W_PANO (MAX_STREAMING_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE+CAM_BG_STITCH_EXT_MEM_SIZE)
#define MED_2_SCENARIO_IVEX_W_JPG_DECODE (MAX_IVEX_MEM_SIZE + MAX_MED_JPG_DEC_EXT_MEM_SIZE)
#define MED_2_SCENARIO_VDOEDT_W_FS_SORT (MAX_MED_VDOEDT_EXT_MEM_SIZE + MAX_FS_SORT_MEM_SIZE)
#define MED_2_SCENARIO_STITCH_PANORAMA_W_JPG_DECODE (MAX_CAM_PANORAMA_EXT_MEM_SIZE+MAX_MED_JPG_DEC_EXT_MEM_SIZE+MAX_MED_JPG_DEC_INT_MEM_SIZE)
#define MED_2_SCENARIO_VRE_W_AUD_W_JPG_DECODE_W_FS_SORT (MAX_VRE_EXT_MEM_SIZE+MAX_FS_SORT_MEM_SIZE+MAX_MED_JPG_DEC_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE)

#define MED_3_SCENARIO_JPG_DECODE_W_M3D_W_AUD_TDMB_FS_SORT (MAX_MED_JPG_DEC_EXT_MEM_SIZE+MAX_M3D_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)
#define MED_3_SCENARIO_JPG_DECODE_W_VOIP_W_AUD_TDMB_FS_SORT (MAX_MED_JPG_DEC_EXT_MEM_SIZE+MAX_VOIP_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)
#define MED_3_SCENARIO_CAM_CAPTURE_W_JPG_DECODE_W_TDMB (MAX_CAM_FILE_BUFFER_LEN+MAX_IMG_DEC_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#if defined(__MP4_DEC_SW_SUPPORT__)|| defined(__H264_DEC_SW_SUPPORT__)
#define MED_3_SCENARIO_VDO_DECODE_W_SNAPSHOT_W_AUD_TDMB_FS_SORT (MAX_MED_VID_DEC_EXT_MEM_SIZE+ 0 +AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)
#else
#define MED_3_SCENARIO_VDO_DECODE_W_SNAPSHOT_W_AUD_TDMB_FS_SORT (MAX_MED_VID_DEC_EXT_MEM_SIZE+ MAX_MED_JPG_ENC_EXT_MEM_SIZE +AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)
#endif

#define MED_3_SCENARIO_VDO_DECODE_W_JPG_DECODE_W_AUD_TDMB_FS_SORT (MAX_MED_VID_DEC_EXT_MEM_SIZE+ MAX_MED_JPG_DEC_EXT_MEM_SIZE +AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)

#define MED_3_SCENARIO_VDO_ENCODE_W_FS_SORT_W_AUD_TDMB  (MAX_MED_VID_ENC_EXT_MEM_SIZE + MAX_FS_SORT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_3_SCENARIO_SWFLASH_W_FS_SORT_W_AUD_TDMB  (MAX_MED_SWFLASH_EXT_MEM_SIZE + MAX_FS_SORT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_3_SCENARIO_JAVA_W_FS_SORT_W_AUD_TDMB  (MAX_J2ME_EXT_MEM_SIZE + MAX_FS_SORT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_3_SCENARIO_STREAMING_W_JPG_DECODE_W_FS_SORT_AUD_TDMB  (MAX_STREAMING_EXT_MEM_SIZE + MAX_MED_JPG_DEC_EXT_MEM_SIZE + MAX_FS_SORT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_3_SCENARIO_MMS_SUPPORT_W_FS_SORT_W_AUD_TDMB  (MAX_MMS_RESIZE_IMAGE_BUF_SIZE + MAX_FS_SORT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_3_SCENARIO_IVEX_W_JPG_DECODE_W_FS_SORT_AUD_TDMB (MAX_IVEX_MEM_SIZE + MAX_MED_JPG_DEC_EXT_MEM_SIZE + MAX_FS_SORT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)
#define MED_3_SCENARIO_CAM_CAPTURE_W_FS_SORT_W_AUD (MAX_MED_CAM_CAP_EXT_MEM_SIZE + MAX_FS_SORT_MEM_SIZE + AUD_EXT_MEM_SIZE)

#if defined(__QQMOVIE_SUPPORT__)
#define MED_4_SCENARIO_QQ_MOVIE_W_VDO_DECODE_W_JPG_DECODE_W_AUD_TDMB_FS_SORT (MAX_QQMOVIE_EXT_MEM_SIZE+MAX_MED_VID_DEC_EXT_MEM_SIZE+ MAX_MED_JPG_DEC_EXT_MEM_SIZE +AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)
#else
#define MED_4_SCENARIO_QQ_MOVIE_W_VDO_DECODE_W_JPG_DECODE_W_AUD_TDMB_FS_SORT (0)
#endif

#define MED_MEM_ALIGN_TO_4(_x)  (((_x) + 3) & ~3) 


/* MED Internal */
#define MED_INT_SCENARIO_DEFAULT MED_MEM_INT_DEFAULT_SIZE
#define MED_INT_SCENARIO_CAM_CAP MAX_MED_CAM_CAP_INT_MEM_SIZE
#define MED_INT_SCENARIO_JPG_ENC MAX_MED_JPG_ENC_INT_MEM_SIZE
#define MED_INT_SCENARIO_JPG_DEC MAX_MED_JPG_DEC_INT_MEM_SIZE
#define MED_INT_SCENARIO_VDO_ENC MAX_MED_VID_ENC_INT_MEM_SIZE
#define MED_INT_SCENARIO_VDO_DEC MAX_MED_VID_DEC_INT_MEM_SIZE
#define MED_INT_SCENARIO_VDO_EDT MAX_VID_EDT_INT_MEM_SIZE
#define MED_INT_SCENARIO_AMR_REC MAX_DEDI_AMR_REC_BUFFER
#define MED_INT_SCENARIO_CAM_PRE MAX_MED_CAM_PREVIEW_INT_MEM_SIZE
/* MED DEFAULT SIZE is multiple of 4 */
#define MED_MEM_INT_DEFAULT_SIZE     (4)
#define MED_MEM_EXT_DEFAULT_SIZE     (4)

#define MED_INT_MEM_SIZE_CONFIG(size)    \
	(MED_MEM_ALIGN_TO_4(size) + MEM_OVERHEAD)

#define MED_MEM_SIZE_CONFIG(size)    \
	(MED_MEM_ALIGN_TO_4(size) + MEM_EXT_OVERHEAD)
#define MED_MEM_CONC2_SIZE(size1, size2)    \
    (MED_MEM_ALIGN_TO_4(size1) + MED_MEM_ALIGN_TO_4(size2) + MEM_EXT_OVERHEAD)
#define MED_MEM_CONC3_SIZE(size1, size2, size3)    \
    (MED_MEM_ALIGN_TO_4(size1) + MED_MEM_ALIGN_TO_4(size2) + MED_MEM_ALIGN_TO_4(size3) + MEM_EXT_OVERHEAD)
#define MED_MEM_CONC4_SIZE(size1, size2, size3, size4)    \
    (MED_MEM_ALIGN_TO_4(size1) + MED_MEM_ALIGN_TO_4(size2) + MED_MEM_ALIGN_TO_4(size3) + MED_MEM_ALIGN_TO_4(size4) + MEM_EXT_OVERHEAD)

typedef union
{
    /* default size */
    kal_uint8 MED_DUFAULT_EXT_SIZE[MED_MEM_EXT_DEFAULT_SIZE];

    /* each single cases */	
    kal_uint8 MED_EXT_CAM_CAPTURE[MED_MEM_SIZE_CONFIG(MAX_MED_CAM_CAP_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_JPG_ENCODE[MED_MEM_SIZE_CONFIG(MAX_MED_JPG_ENC_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_JPG_DECODE[MED_MEM_SIZE_CONFIG(MAX_MED_JPG_DEC_EXT_MEM_SIZE)]; 
    kal_uint8 MED_EXT_VID_ENCODE[MED_MEM_SIZE_CONFIG(MAX_MED_VID_ENC_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_VID_DECODE[MED_MEM_SIZE_CONFIG(MAX_MED_VID_DEC_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_VDOEDT[MED_MEM_SIZE_CONFIG(MAX_VID_EDT_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_WEBCAM[MED_MEM_SIZE_CONFIG(MAX_MED_WEBCAM_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_MMS_SUPPORT[MED_MEM_SIZE_CONFIG(MAX_MMS_RESIZE_IMAGE_BUF_SIZE)];
    kal_uint8 MED_EXT_BARCODE[MED_MEM_SIZE_CONFIG(MAX_BARCODE_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_VOIP[MED_MEM_SIZE_CONFIG(MAX_VOIP_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_STREAMING[MED_MEM_SIZE_CONFIG(MAX_STREAMING_EXT_MEM_SIZE)]; 
    kal_uint8 MED_EXT_J2ME[MED_MEM_SIZE_CONFIG(MAX_J2ME_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_SWFLASH[MED_MEM_SIZE_CONFIG(MAX_MED_SWFLASH_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_M3D[MED_MEM_SIZE_CONFIG(MAX_M3D_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_3D_GAME[MED_MEM_SIZE_CONFIG(MAX_3D_GAME_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_AUD[MED_MEM_SIZE_CONFIG(AUD_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_TDMB[MED_MEM_SIZE_CONFIG(MAX_TDMB_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_CMMB[MED_MEM_SIZE_CONFIG(MAX_CMMB_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_CAM_PREVIEW[MED_MEM_SIZE_CONFIG(MAX_MED_CAM_PREVIEW_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_BCR[MED_MEM_SIZE_CONFIG(MAX_BCR_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_CAM_PANORAMA[MED_MEM_SIZE_CONFIG(MAX_CAM_PANORAMA_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_IVEX[MED_MEM_SIZE_CONFIG(MAX_IVEX_MEM_SIZE)];

    /* 2 scenarios concurrent cases */
    kal_uint8 MED_EXT_JPG_ENCODE_W_AUD_TDMB[MED_MEM_CONC2_SIZE(MAX_MED_JPG_ENC_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_SWFLASH_W_AUD_TDMB[MED_MEM_CONC2_SIZE(MAX_MED_SWFLASH_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_STREAMING_W_AUD_TDMB[MED_MEM_CONC2_SIZE(MAX_STREAMING_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_MMS_SUPPORT_W_AUD_TDMB[MED_MEM_CONC2_SIZE(MAX_MMS_RESIZE_IMAGE_BUF_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_TDMB_W_AUD[MED_MEM_CONC2_SIZE(MAX_TDMB_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_CMMB_W_AUD[MED_MEM_CONC2_SIZE(MAX_CMMB_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_WEBCAM_W_TDMB[MED_MEM_CONC2_SIZE(MAX_MED_WEBCAM_EXT_MEM_SIZE,MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_GGLIVE_W_AUD[MED_MEM_CONC2_SIZE(MAX_GGLIVE_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE)];

    kal_uint8 MED_EXT_CAM_VDOEDT_W_FS_SORT[MED_MEM_CONC2_SIZE(MAX_MED_VDOEDT_EXT_MEM_SIZE,MAX_FS_SORT_MEM_SIZE)];
    kal_uint8 MED_EXT_PANORAMA_W_JPG_DECODE[MED_MEM_CONC2_SIZE(MAX_CAM_PANORAMA_EXT_MEM_SIZE,MAX_MED_JPG_DEC_EXT_MEM_SIZE+MAX_MED_JPG_DEC_INT_MEM_SIZE)];
    kal_uint8 MED_EXT_STREAMING_W_AUD_W_PANO[MED_MEM_CONC2_SIZE(MAX_STREAMING_EXT_MEM_SIZE+AUD_EXT_MEM_SIZE,CAM_BG_STITCH_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_IVEX_W_JPG_DECODE[MED_MEM_CONC2_SIZE(MAX_IVEX_MEM_SIZE,MAX_MED_JPG_DEC_EXT_MEM_SIZE)];
    kal_uint8 MED_EXT_VRE_W_AUD_W_JPG_DECODE_W_FS_SORT[MED_MEM_CONC2_SIZE(MAX_VRE_EXT_MEM_SIZE, MAX_FS_SORT_MEM_SIZE + MAX_MED_JPG_DEC_EXT_MEM_SIZE + AUD_EXT_MEM_SIZE)];


    /* 3 scenarios concurrent cases */
    kal_uint8 MED_EXT_JPG_DECODE_W_M3D_W_AUD_TDMB_FS_SORT[MED_MEM_CONC3_SIZE(MAX_MED_JPG_DEC_EXT_MEM_SIZE,MAX_M3D_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)];
    kal_uint8 MED_EXT_JPG_DECODE_W_VOIP_W_AUD_TDMB_FS_SORT[MED_MEM_CONC3_SIZE(MAX_MED_JPG_DEC_EXT_MEM_SIZE,MAX_VOIP_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)];
    #if defined(__MP4_DEC_SW_SUPPORT__)|| defined(__H264_DEC_SW_SUPPORT__)
    kal_uint8 MED_EXT_VDO_DECODE_W_SNAPSHOT_W_AUD_TDMB_FS_SORT[MED_MEM_CONC3_SIZE(MAX_MED_VID_DEC_EXT_MEM_SIZE,0,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)];
    #else
    kal_uint8 MED_EXT_VDO_DECODE_W_SNAPSHOT_W_AUD_TDMB_FS_SORT[MED_MEM_CONC3_SIZE(MAX_MED_VID_DEC_EXT_MEM_SIZE,MAX_MED_JPG_ENC_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)];
    #endif
    #if !defined(__MP4_DEC_SW_SUPPORT__) && !defined(__H264_DEC_SW_SUPPORT__)
    kal_uint8 MED_EXT_VDO_DECODE_W_JPG_DECODE_W_AUD_TDMB_FS_SORT[MED_MEM_CONC3_SIZE(MAX_MED_VID_DEC_EXT_MEM_SIZE,MAX_MED_JPG_DEC_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)];
    #endif
    kal_uint8 MED_EXT_CAM_CAPTURE_W_JPG_DECODE_W_TDMB[MED_MEM_CONC3_SIZE(MAX_CAM_FILE_BUFFER_LEN,MAX_IMG_DEC_EXT_MEM_SIZE,MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_VDO_ENCODE_W_FS_SORT_W_AUD_TDMB[MED_MEM_CONC3_SIZE(MAX_MED_VID_ENC_EXT_MEM_SIZE,MAX_FS_SORT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_SWFLASH_W_FS_SORT_W_AUD_TDMB[MED_MEM_CONC3_SIZE(MAX_MED_SWFLASH_EXT_MEM_SIZE,MAX_FS_SORT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_JAVA_W_FS_SORT_W_AUD_TDMB[MED_MEM_CONC3_SIZE(MAX_J2ME_EXT_MEM_SIZE ,MAX_FS_SORT_MEM_SIZE,MTV_BG_RECORD_MEM_SIZE)];
    #if defined(__MP4_DEC_SW_SUPPORT__)|| defined(__H264_DEC_SW_SUPPORT__)
        kal_uint8 MED_EXT_STREAMING_W_JPG_DECODE_W_FS_SORT_AUD_TDMB[MED_MEM_CONC3_SIZE(MAX_STREAMING_EXT_MEM_SIZE,MAX_MED_JPG_DEC_EXT_MEM_SIZE,MAX_FS_SORT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+10*1024)];
    #else
        kal_uint8 MED_EXT_STREAMING_W_JPG_DECODE_W_FS_SORT_AUD_TDMB[MED_MEM_CONC3_SIZE(MAX_STREAMING_EXT_MEM_SIZE,MAX_MED_JPG_DEC_EXT_MEM_SIZE,MAX_FS_SORT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    #endif
    kal_uint8 MED_EXT_MMS_SUPPORT_W_FS_SORT_W_AUD_TDMB[MED_MEM_CONC3_SIZE(MAX_MMS_RESIZE_IMAGE_BUF_SIZE ,MAX_FS_SORT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_IVEX_W_JPG_DECODE_W_FS_SORT_AUD_TDMB[MED_MEM_CONC3_SIZE(MAX_IVEX_MEM_SIZE,MAX_MED_JPG_DEC_EXT_MEM_SIZE,MAX_FS_SORT_MEM_SIZE+AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE)];
    kal_uint8 MED_EXT_CAM_CAPTURE_W_FS_SORT_W_AUD[MED_MEM_CONC3_SIZE(MAX_MED_CAM_CAP_EXT_MEM_SIZE,MAX_FS_SORT_MEM_SIZE,AUD_EXT_MEM_SIZE)];

    /* 4 concurrent scenarios case */
#if defined(__QQMOVIE_SUPPORT__)
    kal_uint8 MED_EXT_QQMOVIE_VDO_DECODE_W_JPG_DECODE_W_AUD_TDMB_FS_SORT[MED_MEM_CONC4_SIZE(MAX_QQMOVIE_EXT_MEM_SIZE,MAX_MED_VID_DEC_EXT_MEM_SIZE,MAX_MED_JPG_DEC_EXT_MEM_SIZE,AUD_EXT_MEM_SIZE+MTV_BG_RECORD_MEM_SIZE+MAX_FS_SORT_MEM_SIZE)];
#endif    
} med_ext_mem_union;

#ifdef MBM_IMIBASE_SUPPORT
#define MED_EXT_MEM_SIZE sizeof(med_ext_mem_union) + 400 * 1024
#else //MBM_IMIBASE_SUPPORT
#define MED_EXT_MEM_SIZE sizeof(med_ext_mem_union)
#endif /*MBM_IMIBASE_SUPPORT*/

typedef union
{
    kal_uint8 MED_DUFAULT_INT_SIZE[MED_INT_MEM_SIZE_CONFIG(MED_MEM_INT_DEFAULT_SIZE)];
    kal_uint8 MED_INT_CAM_CAPTURE[MED_INT_MEM_SIZE_CONFIG(MAX_MED_CAM_CAP_INT_MEM_SIZE)];
    kal_uint8 MED_INT_JPG_ENCODE[MED_INT_MEM_SIZE_CONFIG(MAX_MED_JPG_ENC_INT_MEM_SIZE )];
    kal_uint8 MED_INT_JPG_DECODE[MED_INT_MEM_SIZE_CONFIG(MAX_MED_JPG_DEC_INT_MEM_SIZE)]; 
    kal_uint8 MED_INT_VID_ENCODE[MED_INT_MEM_SIZE_CONFIG(MAX_MED_VID_ENC_INT_MEM_SIZE)];
    kal_uint8 MED_INT_VID_DECODE[MED_INT_MEM_SIZE_CONFIG(MAX_MED_VID_DEC_INT_MEM_SIZE)];
    kal_uint8 MED_INT_VDOEDT[MED_INT_MEM_SIZE_CONFIG(MAX_VID_EDT_INT_MEM_SIZE)];
    kal_uint8 MED_INT_CAM_PREVIEW[MED_INT_MEM_SIZE_CONFIG(MAX_MED_CAM_PREVIEW_INT_MEM_SIZE)];
    kal_uint8 MED_INT_DEDI_AMR_REC_BUFFER[MED_INT_MEM_SIZE_CONFIG(MAX_DEDI_AMR_REC_BUFFER)];
} med_int_mem_union;

#define MED_INT_MEM_SIZE sizeof(med_int_mem_union)

#endif
